<template>
    <div>
        已授权登录,刷新后登录状态失效
    </div>

</template>

<script>
import constant from "~/constants";

export default {
    methods: {
        initCsrf() {
            this.$store.dispatch('backend/CsrfCookie');
        },
        // 登录
        oneClickLogin() {
            this.$store.dispatch('manager/OneClickLogin', {user_id: this.$route.query.user_id}).then(res => {
                this.loading = false;
                this.loginSuccess();
            }).catch(error => {
                this.loading = false;
            });
        },
        loginSuccess() {
            this.$store.dispatch('backend/Menu');
            this.$message.success('授权登录成功');
            this.$store.dispatch('manager/Info').then(() => {
                this.$tabs.reset('/dashboard');
            });
        },
        resetTitle() {
            document.title = constant.title.ONE_CLICK_LOGIN
        }
    },
    created() {
        this.resetTitle();
        this.initCsrf();
        this.oneClickLogin();
    }
}
</script>

<style lang="scss" scoped>
</style>
